<template>
  <div class="like-page">
    <van-nav-bar fixed title="我的点赞" />
    <van-list
      v-model="loading"
      :finished="finished"
      finished-text="没有更多了"
      @load="onLoad"
      offset="50"
    >
      <ArticleItem v-for="item in list" :key="item.id" :item="item" />
    </van-list>
  </div>
</template>
<script>
import { CollectLikeAPI } from '@/api/collect'
export default {
  name: 'LikeCom',
  data () {
    return {
      obj: {
        optType: 1,
        pageSize: 5,
        page: 1,

      },
      loading: false,
      finished: false,
      total: 0,
      list: []
    }
  },
  created () {

  },
  computed: {
  },
  methods: {
    onLoad () {

      // if (this.obj.page * this.obj.pageSize > this.total) {


      //   this.finished = true;

      //   return
      // }
      if (this.list.length > 10) {
        this.finished = true
        return
      }

      this.getData()
      this.obj.page++

      // }, 1000);
    },
    async getData () {
      const res = await CollectLikeAPI(this.obj)
      // console.log(res, res.data.total, 8888)
      this.total = res.data.total
      // console.log(this.total)

      this.list = [...this.list, ...res.data.rows]
      this.loading = false;
    }
  }
}
</script>
<style lang='less'  scoped>
.like-page {
  margin-bottom: 50px;
  margin-top: 44px;
}
</style>
